package com.study.spmongodb.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author MI
 * @version 1.0
 * @date 2020/10/14 15:41
 * <p>
 * 1 配置好拦截器，拦截哪些请求
 * 2 把这些配置放置在容器中
 */
@Component
public class JwtInterceptor implements HandlerInterceptor {

    /**
     * preHandle 进入控制器方法之前执行的内容
     * postHandler 执行控制器方法之后执行的内容
     * afterCompletion:响应结束之前执行的内容。
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("经过了拦截器");

        final HandlerMethod handlerMethod = (HandlerMethod) handler;
        return true;
    }
}
